home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gscspace.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  5KB  |  158 lines

  1. /* Copyright (C) 1991, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gscspace.h */
  20. /* Client interface to color spaces for Ghostscript library */
  21.  
  22. #ifndef gscspace_INCLUDED
  23. #  define gscspace_INCLUDED
  24.  
  25. /* Color space type indices */
  26. typedef enum {
  27.         /* Supported in all configurations */
  28.     gs_color_space_index_DeviceGray = 0,
  29.     gs_color_space_index_DeviceRGB,
  30.     gs_color_space_index_DeviceCMYK,
  31.         /* Supported in Level 2 only */
  32.     gs_color_space_index_CIEBasedABC,
  33.     gs_color_space_index_CIEBasedA,
  34.     gs_color_space_index_Separation,
  35.     gs_color_space_index_Indexed,
  36.     gs_color_space_index_Pattern
  37. } gs_color_space_index;
  38.  
  39. /*
  40.  * Color spaces are complicated because different spaces involve
  41.  * different kinds of parameters, as follows:
  42.  
  43. Space        Space parameters        Color parameters
  44. -----        ----------------        ----------------
  45. DeviceGray    (none)                1 real [0-1]
  46. DeviceRGB    (none)                3 reals [0-1]
  47. DeviceCMYK    (none)                4 reals [0-1]
  48. CIEBasedABC    dictionary            3 reals
  49. CIEBasedA    dictionary            1 real
  50. Separation    name, alt_space, tint_xform    1 real [0-1]
  51. Indexed        base_space, hival, lookup    1 int [0-hival]
  52. Pattern        colored: (none)            dictionary
  53.         uncolored: base_space        dictionary + base space params
  54.  
  55. Space        Underlying or alternate space
  56. -----        -----------------------------
  57. Separation    Device, CIE
  58. Indexed        Device, CIE
  59. Pattern        Device, CIE, Separation, Indexed
  60.  
  61.  */
  62.  
  63. /* Color space type objects */
  64. struct gs_client_color_s;
  65. struct gs_color_space_s;
  66. struct gx_device_color_s;
  67. /* Map a color to a device color. */
  68. #define cs_proc_remap_color(proc)\
  69.   int proc(P4(const struct gs_client_color_s *,\
  70.           const struct gs_color_space_s *,\
  71.           struct gx_device_color_s *,\
  72.           gs_state *))
  73. /* Install the color space in a graphics state. */
  74. #define cs_proc_install_cspace(proc)\
  75.   int proc(P2(struct gs_color_space_s *, gs_state *))
  76. cs_proc_install_cspace(gx_no_install_cspace);
  77. /* Adjust reference counts of indirect components. */
  78. #define cs_proc_adjust_count(proc)\
  79.   int proc(P3(struct gs_color_space_s *, gs_state *, int))
  80. cs_proc_adjust_count(gx_no_adjust_count);
  81. #define cs_adjust_count(pgs, delta)\
  82.   (*(pgs)->color_space->type->adjust_count)((pgs)->color_space, pgs, delta)
  83. /* Color space types (classes): */
  84. typedef struct gs_color_space_type_s {
  85.     gs_color_space_index index;
  86.     int num_components;        /* # of components in a color */
  87.                     /* in this space, -1 if variable */
  88.     cs_proc_remap_color((*remap_color));
  89.     cs_proc_install_cspace((*install_cspace));
  90.     cs_proc_adjust_count((*adjust_count));
  91. } gs_color_space_type;
  92.  
  93. /* Standard color space types */
  94. extern const gs_color_space_type
  95.     gs_color_space_type_DeviceGray,
  96.     gs_color_space_type_DeviceRGB,
  97.     gs_color_space_type_DeviceCMYK;
  98.  
  99.     /* Base color spaces (Device and CIE) */
  100.  
  101. typedef struct gs_cie_abc_s gs_cie_abc;
  102. typedef struct gs_cie_a_s gs_cie_a;
  103. #define gs_base_cspace_params\
  104.     gs_cie_abc *abc;\
  105.     gs_cie_a *a
  106. typedef struct gs_base_color_space_s {
  107.     const gs_color_space_type *type;
  108.     union {
  109.         gs_base_cspace_params;
  110.     } params;
  111. } gs_base_color_space;
  112.  
  113.     /* Paint (non-pattern) color spaces (base + Separation + Indexed) */
  114.  
  115. typedef ulong gs_separation_name;        /* BOGUS */
  116.  
  117. typedef struct gs_separation_params_s {
  118.     gs_separation_name sname;
  119.     gs_base_color_space alt_space;
  120.     int (*tint_transform)(P2(floatp, float *));
  121. } gs_separation_params;
  122. typedef struct gs_indexed_params_s {
  123.     gs_base_color_space base_space;
  124.     int hival;
  125.     union {
  126.         const byte *table;
  127.         int (*proc)(P2(int, float *));
  128.     } lookup;
  129.     int use_proc;        /* 0 = use table, 1 = use proc */
  130. } gs_indexed_params;
  131. #define gs_paint_cspace_params\
  132.     gs_base_cspace_params;\
  133.     gs_separation_params separation;\
  134.     gs_indexed_params indexed
  135. typedef struct gs_paint_color_space_s {
  136.     const gs_color_space_type *type;
  137.     union {
  138.         gs_paint_cspace_params;
  139.     } params;
  140. } gs_paint_color_space;
  141.  
  142.     /* General color spaces (including patterns) */
  143.  
  144. typedef struct gs_pattern_params_s {
  145.     int has_base_space;
  146.     gs_paint_color_space base_space;
  147. } gs_pattern_params;
  148. struct gs_color_space_s {
  149.     const gs_color_space_type *type;
  150.     union {
  151.         gs_paint_cspace_params;
  152.         gs_pattern_params pattern;
  153.     } params;
  154. };
  155. typedef struct gs_color_space_s gs_color_space;
  156.  
  157. #endif                    /* gscspace_INCLUDED */
  158.